﻿@using YesSql.Samples.Web.Models
@using YesSql.Samples.Web.ViewModels
@using System.Collections.Generic

@model BlogPostViewModel
<head>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
</head>

<body class="m-5">

    <form asp-action="IndexPost" method="post">
        <input type="search" asp-for="Search.OriginalSearchText" type="hidden"></input>
        

        <div class="form-group row mb-3">
            <label asp-for="Search.SearchText" class="col-2 align-self-center">Search</label>
            <div class="col-10">
                <input class="form-control" type="search" asp-for="Search.SearchText"></input>
            </div>
        </div>

        <div class="form-group row mb-3">
            <label asp-for="Search.SelectedStatus" class="col-2 align-self-center">Status</label>
            <div class="col-10">
                <select class="form-control" asp-for="Search.SelectedStatus" asp-items="Model.Search.Statuses"></select>
            </div>
        </div>

        <div class="form-group row mb-3">
            <label asp-for="Search.SelectedSort" class="col-2 align-self-center">Sort</label>
            <div class="col-10">
                <select class="form-control" asp-for="Search.SelectedSort" asp-items="Model.Search.Sorts"></select>
            </div>     

        </div>
   
        <button class="btn btn-primary d-flex ms-auto mb-3" type="submit">Search</button>   
    </form>

    @foreach (var blogPost in Model.BlogPosts)
    {
        <div class="card">
            <div class="card-body">
                <h2>@blogPost.Title</h2>
                <i>By: @blogPost.Author - Posted: @@ @blogPost.PublishedUtc</i>
                <p>@blogPost.Content</p>
            </div>
        </div>
    }


</body>
